package com.wodsy.phoenix.dataobject.orderc.model;

import com.wodsy.phoenix.dataobject.base.PhoenixObject;

import javax.persistence.*;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Order entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_order", catalog = "orderc")
public class Order extends PhoenixObject {

	// Fields

	private Long id;
	private Integer version;
	private Integer buyerUserId;
	private Integer sellerUserId;
	private Integer shopId;
	private Integer originalPrice;
	private Integer actualPrice;
	private OrderSource source;
	private OrderStatus status;
	private Long mergerId;
	private Long tradeQuotationId;
	private String sellerRemark;
	private String buyerRemark;
	private Boolean buyerVisible;
	private Boolean sellerVisible;
	private Boolean closed;
	private CloseType closeType;
	private String closeReason;
	private Date createTime;
	private Date updateTime;

	// Constructors

	/** default constructor */
	public Order() {
	}

	/** minimal constructor */
	public Order(Integer buyerUserId, Integer sellerUserId, Integer shopId,
				 Integer originalPrice, Integer actualPrice, OrderSource source,
				 OrderStatus status, Date createTime) {
		this.buyerUserId = buyerUserId;
		this.sellerUserId = sellerUserId;
		this.shopId = shopId;
		this.originalPrice = originalPrice;
		this.actualPrice = actualPrice;
		this.source = source;
		this.status = status;
		this.createTime = createTime;
	}

	/** full constructor */
	public Order(Integer buyerUserId, Integer sellerUserId, Integer shopId,
				 Integer originalPrice, Integer actualPrice, OrderSource source,
				 OrderStatus status, Long mergerId, Long tradeQuotationId,
				 String sellerRemark, String buyerRemark, Boolean buyerVisible,
				 Boolean sellerVisible, Boolean closed, CloseType closeType,
				 String closeReason, Date createTime, Date updateTime) {
		this.buyerUserId = buyerUserId;
		this.sellerUserId = sellerUserId;
		this.shopId = shopId;
		this.originalPrice = originalPrice;
		this.actualPrice = actualPrice;
		this.source = source;
		this.status = status;
		this.mergerId = mergerId;
		this.tradeQuotationId = tradeQuotationId;
		this.sellerRemark = sellerRemark;
		this.buyerRemark = buyerRemark;
		this.buyerVisible = buyerVisible;
		this.sellerVisible = sellerVisible;
		this.closed = closed;
		this.closeType = closeType;
		this.closeReason = closeReason;
		this.createTime = createTime;
		this.updateTime = updateTime;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "buyer_user_id", nullable = false)
	public Integer getBuyerUserId() {
		return this.buyerUserId;
	}

	public void setBuyerUserId(Integer buyerUserId) {
		this.buyerUserId = buyerUserId;
	}

	@Column(name = "seller_user_id", nullable = false)
	public Integer getSellerUserId() {
		return this.sellerUserId;
	}

	public void setSellerUserId(Integer sellerUserId) {
		this.sellerUserId = sellerUserId;
	}

	@Column(name = "shop_id", nullable = false)
	public Integer getShopId() {
		return this.shopId;
	}

	public void setShopId(Integer shopId) {
		this.shopId = shopId;
	}

	@Column(name = "original_price", nullable = false)
	public Integer getOriginalPrice() {
		return this.originalPrice;
	}

	public void setOriginalPrice(Integer originalPrice) {
		this.originalPrice = originalPrice;
	}

	@Column(name = "actual_price", nullable = false)
	public Integer getActualPrice() {
		return this.actualPrice;
	}

	public void setActualPrice(Integer actualPrice) {
		this.actualPrice = actualPrice;
	}

	@Column(name = "source", nullable = false)
	public OrderSource getSource() {
		return this.source;
	}

	public void setSource(OrderSource source) {
		this.source = source;
	}

	@Column(name = "status", nullable = false)
	public OrderStatus getStatus() {
		return this.status;
	}

	public void setStatus(OrderStatus status) {
		this.status = status;
	}

	@Column(name = "merger_id")
	public Long getMergerId() {
		return this.mergerId;
	}

	public void setMergerId(Long mergerId) {
		this.mergerId = mergerId;
	}

	@Column(name = "trade_quotation_id")
	public Long getTradeQuotationId() {
		return this.tradeQuotationId;
	}

	public void setTradeQuotationId(Long tradeQuotationId) {
		this.tradeQuotationId = tradeQuotationId;
	}

	@Column(name = "seller_remark", length = 200)
	public String getSellerRemark() {
		return this.sellerRemark;
	}

	public void setSellerRemark(String sellerRemark) {
		this.sellerRemark = sellerRemark;
	}

	@Column(name = "buyer_remark", length = 200)
	public String getBuyerRemark() {
		return this.buyerRemark;
	}

	public void setBuyerRemark(String buyerRemark) {
		this.buyerRemark = buyerRemark;
	}

	@Column(name = "buyer_visible")
	public Boolean getBuyerVisible() {
		return this.buyerVisible;
	}

	public void setBuyerVisible(Boolean buyerVisible) {
		this.buyerVisible = buyerVisible;
	}

	@Column(name = "seller_visible")
	public Boolean getSellerVisible() {
		return this.sellerVisible;
	}

	public void setSellerVisible(Boolean sellerVisible) {
		this.sellerVisible = sellerVisible;
	}

	@Column(name = "closed")
	public Boolean getClosed() {
		return this.closed;
	}

	public void setClosed(Boolean closed) {
		this.closed = closed;
	}

	@Column(name = "close_type")
	public CloseType getCloseType() {
		return this.closeType;
	}

	public void setCloseType(CloseType closeType) {
		this.closeType = closeType;
	}

	@Column(name = "close_reason", length = 50)
	public String getCloseReason() {
		return this.closeReason;
	}

	public void setCloseReason(String closeReason) {
		this.closeReason = closeReason;
	}

	@Column(name = "create_time", nullable = false, length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}



	/**
	 * 订单的状态类型
	 */
	public static enum OrderStatus {
		/**等待买家支付，实在太难翻译，所以用拼音*/
		DAIZHIFU("待支付"),
		/**订单支付成功，等待卖家发货*/
		ZHIFUCHENGGONG("等待发货"),
		/**卖家已发货，等待买家确认收货*/
		YIFAHUO("已发货"),
		/**确认收货，交易成功*/
		QUERENSHOUHUO("交易成功"),
		/**交易成功，订单进入锁定，无法修改，无法进行退换货处理*/
		JIAOYICHENGGONG("交易锁定");
		private String value;

		public String getValue() {
			return value;
		}

		private OrderStatus(String value) {
			this.value = value;
		}
	}

	/**
	 * 订单的来源
	 */
	public static enum OrderSource {
		/**
		 * 0:web商城
		 */
		WEB,
		/**
		 * 1:h5商城
		 */
		H5,
		/**
		 * 2:微信
		 */
		WEIXIN;

	}

	/**
	 * 订单关闭类型
	 */
	public static enum CloseType {
		/**卖家关闭*/
		SELLERCLOSE,
		/**买家关闭*/
		BUYERCLOSE,
		/**超时由系统关闭*/
		SYSTEMCLOSE

	}

}